<template>
  <div class="register">
    <div class="title">注册页</div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="phone"
        name="用户名"
        placeholder="请输入账号"
        :rules="[
          { required: true, pattern: /^1[3-9]\d{9}$/, message: '请输入账号' },
        ]"
      />
      <van-field
        v-model="pass"
        type="password"
        name="密码"
        placeholder="请输入密码"
        :rules="[{ required: true, pattern: /^\d{6}$/, message: '请输入密码' }]"
      />
      <van-field
        v-model="checkpass"
        type="password"
        name="密码"
        placeholder="请输入确认密码"
        :rules="[
          { required: true, pattern: /^\d{6}$/, message: '请输入确认密码' },
        ]"
      />
      <div style="margin: 16px 0">
        <van-button round block type="primary" native-type="submit"
          >注册</van-button
        >
      </div>
    </van-form>
  </div>
</template>
<script>
import { user_register } from "../utils/api";
export default {
  data() {
    return {
      phone: "",
      pass: "",
      checkpass: "",
    };
  },
  methods: {
    onSubmit() {
      // console.log("submit", this.$data);
      user_register(this.$data).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          //保存token

          localStorage.setItem("token", res.data.token);
          //跳转到首页
          this.$router.push("/login");
        }
      });
    },
  },
};
</script>
<style lang="scss">
.register {
  margin: 0 20px;
  .title {
    text-align: center;
    padding: 50px 0;
  }
  .van-field {
    border: 1px solid #ccc;
    border-radius: 30px;
    margin: 30px 0;
  }
}
</style>
{
        path:'/index',
        // element:(<Index />),
        element:<AuthComponent permission_no={1}><Index /></AuthComponent>,
        children:[
            {
                path:'/index/home',
                element:<AuthComponent permission_no={1}><Home /></AuthComponent>,
            },
            {
                path:'/index/client',
                element:(<Client />),
                children:[
                    {
                        path:'/index/client/clientmanage',
                        element:<AuthComponent permission_no={1}>< ClientManage /></AuthComponent>,
                    },
                   
                ]
            },
            {
                path:'/index/service',
                element:<AuthComponent permission_no={1}>< Service /></AuthComponent>,
            },
            {
                path:'/index/staff',
                element:<AuthComponent permission_no={1}>< Staff/></AuthComponent>,
                children:[
                    {
                        path:'/index/staff/rolemanage',
                        element:<AuthComponent permission_no={1}>< RoleManage /></AuthComponent>,
                    },
                    {
                        path:'/index/staff/staffManage',
                        element:<AuthComponent permission_no={1}><StaffManage /></AuthComponent>,
                    },
                ]
                
            },
            {
                path:'/index/system',
                element:<AuthComponent permission_no={1}>< System/></AuthComponent>,
                children:[
                    {
                        path:'/index/system/onlinesystem',
                        element:<AuthComponent permission_no={1}>< Onlinesystem /></AuthComponent>,
                    },
                    
                    {
                        path:'/index/system/realtimedata',
                        element:<AuthComponent permission_no={1}>< Realtimedata /></AuthComponent>,
                       
                    },
                    {
                        path:'/index/system/historicaldata',
                        element:<AuthComponent permission_no={1}>< Historicaldata /></AuthComponent>,
                        children:[
                            {
                                path:'/index/system/historicaldata/pandect',
                                element:<AuthComponent permission_no={1}>< Pandect/></AuthComponent>,
                            },
                        ]
                    },
                ]
            },
            {
                path:'/index',
                element:(<Navigate to="/index/home"></Navigate>)
            },
            {
                path:'*',
                element:(<NotFound />)
            }, 
        ]
    },
    {
        path:'/login',
        element:(<Login />)
    },
    {
        path:'/register',
        element:(<Register />)
    },
    {
        path:'/',
        //element:(<Navigate to="/index"></Navigate>)
        element:<AuthComponent><Navigate to="/index"></Navigate></AuthComponent>
    },
    {
        path:'*',
        // element:(<NotFound />)
        element:<AuthComponent><NotFound /></AuthComponent>
    }, 
   